/**
 * @author Jason Pratt
 */

package edu.cmu.cs.stage3.alice.authoringtool.util;

import edu.cmu.cs.stage3.alice.core.event.PropertyListener;

public class ObjectArrayPropertyItem extends edu.cmu.cs.stage3.alice.core.Property {

 protected edu.cmu.cs.stage3.alice.core.property.ObjectArrayProperty objectArrayProperty;
 protected int index;
 protected Class type;

 public ObjectArrayPropertyItem( edu.cmu.cs.stage3.alice.core.Element element, edu.cmu.cs.stage3.alice.core.property.ObjectArrayProperty objectArrayProperty, int index, Class type ) {
  super( element, "item " + index, null, objectArrayProperty.getComponentType() );
  //  this.setIsAcceptingOfNull( true );
  this.objectArrayProperty = objectArrayProperty;
  this.index = index;
  this.type = type;
 }

 public edu.cmu.cs.stage3.alice.core.property.ObjectArrayProperty getObjectArrayProperty() {
  return objectArrayProperty;
 }

 public int getIndex() {
  return index;
 }

 //Rem @Override
 public Object get() {
  return objectArrayProperty.get( index );
 }

 //Rem @Override
 public Object getValue() {
  return objectArrayProperty.get( index );
 }

 //Rem @Override
 public Class getValueClass() {
  return type;
 }

 //Rem @Override
 public void set( Object value ) throws IllegalArgumentException {
  objectArrayProperty.set( index, value );
  //super.set( value );
 }

 public void dispose() {
  edu.cmu.cs.stage3.alice.core.event.PropertyListener[] listeners = this.getPropertyListeners();
  String str = ""; //L
  System.out.println("ObjectArrayPropertyItem.java: dispose(): this.removePropertyListener");
  //LOB for (PropertyListener listener : listeners)
  int t_tam = listeners!=null ? listeners.length : 0;
  for (int i_i=0; i_i<t_tam; i_i++) {
   str = " "+i_i+": "+super.getClass()+": "+super.getName()+", "+super.getValue();
   System.out.println(str);
   this.removePropertyListener( listeners[i_i] ); //L this.removePropertyListener( listener );
  }
  objectArrayProperty = null;
 }


}
